import {Button} from 'antd';
import { WeaLocaleProvider } from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;

//获取Primary的Button
const getPrimaryButton = (func,loading,text,ecId) => {
    return (<Button ecId={`${ecId}_Button@sbb9zq@primaryLoading`} 
                type="primary" 
                style={{marginRight:5}} 
                onClick={func} 
                disabled={loading}>{text}</Button>);
}

//获取Primary的Button
const getPrimaryCheckButton = (func,tableStore,text,ecId) => {
    return (<Button ecId={`${ecId}_Button@exv7wh@primaryTableStore`} 
                type="primary" 
                style={{marginRight:5}} 
                onClick={func} 
                disabled={tableStore.selectedRowKeys.length>0?false:true}>{text}</Button>);
}

//获取ghost的Button
const getGhostButton = (func,loading,text,ecId) => {
    return (<Button ecId={`${ecId}_Button@wp70e8@ghost`} 
                type="ghost" 
                style={{marginRight:5}} 
                onClick={func} 
                disabled={loading}>{text}</Button>);
}

//获取自定义的Button
const getCustomizeButton = (type,style,func,loading,text,ecId) => {
    return (<Button ecId={`${ecId}_Button@u3imne@custom`} 
                type={type} 
                style={style} 
                onClick={func} 
                disabled={loading}>{text}</Button>);
}

//获取动态的button 列表
const getListButton = (that,loading,menu,ecId) => {
    let btns = [];
    mobx.toJS(menu).map(item => {
        btns.push(<Button ecId={`${ecId}_Button@7byypi@dynamic`} type='primary' disabled={loading} onClick={() => {that[item.menuFun] && that[item.menuFun]()}}>{item.menuName}</Button>);
    });

    return btns;
}

export {
    getPrimaryButton,
    getPrimaryCheckButton,
    getGhostButton,
    getCustomizeButton,
    getListButton
}